package com.bookstore.db;

public class BookStoreDB {

	/*
	 * Estructura de la Base de datos SQLLite
	 */

	public static final String KEY_ROWID = "_id";
	
	/*
	 * Nombre de las tablas
	 */

	protected static final String T_CATEGORIA = "t001_categoria";
	protected static final String T_LIBRO = "t002_libro";
	protected static final String T_USUARIO = "t003_usuario";
	protected static final String T_COMPRA = "t004_compra";
	protected static final String T_ITEM_COMPRA = "t005_item_compra";
	protected static final String T_TDC = "t006_tdc";
	
	protected static final String CATEGORIA = "create table "+T_CATEGORIA+" ("+KEY_ROWID+" integer primary key autoincrement, "
			+ "codigo text not null, " 
			+ "title text not null, " 
			+ "description text not null); ";

	protected static final String LIBRO = "create table "+T_LIBRO+" ("+KEY_ROWID+" integer primary key autoincrement, "
			+ "codigo text not null, "
			+ "title text not null, "
			+ "description text not null, "
			+ "autor text not null, "
			+ "imageUrl text not null, "
			+ "disponible integer not null, "
			+ "precio double not null, " 
			+ "id_categoria integer not null);";

	protected static final String USUARIO = "create table "+T_USUARIO+" ("+KEY_ROWID+" integer primary key autoincrement, "
			+ "nombre text not null, "
			+ "apellido text not null, "
			+ "correo text not null, "
			+ "telefono text not null, "
			+ "id_tdc integer not null, "
			+ "usuario text not null, " 
			+ "clave text not null); ";

	protected static final String COMPRA = "create table "+T_COMPRA+" ("+KEY_ROWID+" integer primary key autoincrement, "
			+ "usuario text not null, "
			+ "fecha date not null, "
			+ "total double not null); ";

	protected static final String ITEM_COMPRA = "create table "+T_ITEM_COMPRA+" ("+KEY_ROWID+" integer primary key autoincrement, "
			+ "id_libro integer not null, " 
			+ "id_compra integer not null); ";
	
	protected static final String TDC = "create table "+T_TDC+" ("+KEY_ROWID+" integer primary key autoincrement, "
			+ "numero text not null, " 
			+ "tipo text not null, " 
			+ "codigo_seguridad integer not null); ";

	/*
	 * Parametros de Configuracion
	 */
	protected static final String DATABASE_NAME = "bookstore";
	protected static final int DATABASE_VERSION = 2;

	
}
